/**
 * area模块接口
 */
const AV = require("leanengine");
const BaseService = require("./baseService");
class Service extends BaseService {
  constructor() {
    super();
  }

  // 获取模块信息
  async getModuleInfo() {
    let city = new AV.Query("City");
    let area = new AV.Query("Area");
    let cinema = new AV.Query("Cinema");
    let film = new AV.Query("Film");
    let banner = new AV.Query("Banner");
    try {
      let res = await Promise.all([
        city.count(),
        area.count(),
        cinema.count(),
        film.count(),
        banner.count()
      ]);
      let info = {
        code: "666",
        msg: "success",
        list: [
          {
            name: "city",
            cnName: "城市",
            unit: "座",
            count: res[0]
          },
          {
            name: "area",
            unit: "个",
            cnName: "地区",
            count: res[1]
          },
          {
            name: "cinema",
            cnName: "影院",
            unit: "个",
            count: res[2]
          },
          {
            name: "film",
            cnName: "电影",
            unit: "部",
            count: res[3]
          },
          {
            name: "swiper",
            unit: "张",
            cnName: "轮播图",
            count: res[4]
          }
        ]
      };
      return info;
    } catch (error) {
      this.errInfo(error);
    }
  }
}

module.exports = new Service();
